package com.blacktry.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blacktry.entity.model.TrainingProgram;
import com.blacktry.entity.model.Vo.TrainingProgramOneVO;
import com.blacktry.entity.model.Vo.TrainingProgramVO;
import com.blacktry.entity.model.request.TrainingProgramRequest;
import com.blacktry.mapper.TrainingProgramMapper;
import com.blacktry.service.TrainingProgramService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil;
import lombok.val;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author blackTry
 * @since 2021-12-12
 */
@Service
public class TrainingProgramServiceImpl extends ServiceImpl<TrainingProgramMapper, TrainingProgram> implements TrainingProgramService {

    @Autowired
    TrainingProgramService trainingProgramService;
    @Override
    public Map<Integer, List<TrainingProgramOneVO>> findTrainByGrade(TrainingProgramRequest trainingProgramRequest, Page<TrainingProgramVO> trainingProgramPage) {
        Page<TrainingProgramVO>  list= this.baseMapper.findTrainByGrade(trainingProgramRequest,trainingProgramPage);
        Map<Integer,List<TrainingProgramOneVO>> map = new HashMap<>();
        for(TrainingProgramVO item:list.getRecords()){
            map.put(item.getStartSemester(),item.getTrainingProgramOneVOList());
        }
        return map;
    }

    @Override
    public List<Integer> selectGrade() {
        return this.baseMapper.selectGrade();
    }
}
